package tr3dtris.game.controller.inputMapper;

import java.awt.event.KeyEvent;
import tr3dtris.game.GameActions;

/**
 * Class that provides a default input mapping to user actions.
 * @author Luciano Mammino <loige@hotmail.com>
 * @author Andrea Mangano <kapitan0@hotmail.it>
 * @version 0.1
 * @since 0.1
 */
public class DefaultInputMapper extends AbstractInputMapper
{

    /**
     * Constructor. Creates a new <DefaultInputMapper> for a given <GameActions>
     * instace.
     * @param gameActions
     */
    public DefaultInputMapper(GameActions gameActions)
    {
        super(gameActions);
    }


    /**
     * {@inheritDoc}
     */
    public void parseKeyTyped(KeyEvent e) {
        //not needed
    }

    /**
     * {@inheritDoc}
     */
    public void parseKeyPressed(KeyEvent e) {
        switch(e.getKeyCode())
        {
            case KeyEvent.VK_Z:
                this.ccwRotateCurrentPiece();
                break;

            case KeyEvent.VK_X:
                this.cwRotateCurrentPiece();
                break;

            case KeyEvent.VK_RIGHT:
                this.moveCurrentPieceRight();
                break;

            case KeyEvent.VK_LEFT:
                this.moveCurrentPieceLeft();
                break;

            case KeyEvent.VK_DOWN:
                this.moveCurrentPieceDown();
                break;

            case KeyEvent.VK_UP:
                this.moveCurrentPieceUp();
                break;

            case KeyEvent.VK_SPACE:
                this.dropCurrentPiece();
                break;

            case KeyEvent.VK_ENTER:
                this.start();
                break;

            case KeyEvent.VK_P:
                this.pause();
                break;

            case KeyEvent.VK_R:
                this.restart();
                break;
        }
    }

    /**
     * {@inheritDoc}
     */
    public void parseKeyReleased(KeyEvent e) {
        //not needed
    }

}
